This is for consistency with other wrapping list constructors.
We want them all to be transfer full, allow-none.
Also make the constructor return GtkMultiSelection *.
Update all callers.
sort_model = gtk_sort_list_model_new (gtk_color_list_new (0), NULL);
gtk_sort_list_model_set_incremental (sort_model, TRUE);
- selection = GTK_MULTI_SELECTION (gtk_multi_selection_new (G_LIST_MODEL (sort_model)));
+ selection = gtk_multi_selection_new (G_LIST_MODEL (sort_model));
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "Colors");
/**
* gtk_multi_selection_new:
- * @model: (transfer none): the #GListModel to manage
+ * @model: (allow-none) (transfer full): the #GListModel to manage, or %NULL
*
* Creates a new selection to handle @model.
*
- * Returns: (transfer full) (type GtkMultiSelection): a new #GtkMultiSelection
+ * Returns: (transfer full): a new #GtkMultiSelection
**/
-GListModel *
+GtkMultiSelection *
gtk_multi_selection_new (GListModel *model)
{
+ GtkMultiSelection *self;
+
g_return_val_if_fail (G_IS_LIST_MODEL (model), NULL);
- return g_object_new (GTK_TYPE_MULTI_SELECTION,
+ self = g_object_new (GTK_TYPE_MULTI_SELECTION,
"model", model,
NULL);
+
+ /* consume the reference */
+ g_clear_object (&model);
+
+ return self;
}
/**
G_DECLARE_FINAL_TYPE (GtkMultiSelection, gtk_multi_selection, GTK, MULTI_SELECTION, GObject)
GDK_AVAILABLE_IN_ALL
-GListModel * gtk_multi_selection_new (GListModel *model);
+GtkMultiSelection * gtk_multi_selection_new (GListModel *model);
GDK_AVAILABLE_IN_ALL
-GListModel * gtk_multi_selection_get_model (GtkMultiSelection *self);
+GListModel * gtk_multi_selection_get_model (GtkMultiSelection *self);
GDK_AVAILABLE_IN_ALL
-void gtk_multi_selection_set_model (GtkMultiSelection *self,
- GListModel *model);
+void gtk_multi_selection_set_model (GtkMultiSelection *self,
+ GListModel *model);
G_END_DECLS
GtkSelectionModel *result;
GString *changes;
- result = GTK_SELECTION_MODEL (gtk_multi_selection_new (G_LIST_MODEL (store)));
+ result = GTK_SELECTION_MODEL (gtk_multi_selection_new (g_object_ref (G_LIST_MODEL (store))));
changes = g_string_new ("");
g_object_set_qdata_full (G_OBJECT(result), changes_quark, changes, free_changes);